package coder.nav.model.vo;

import coder.nav.enums.NavCashFlagEnums;
import lombok.Data;

import java.math.BigDecimal;
import java.util.*;

/**
 * 柱状图
 * @author Bosen 2024/10/16 16:32
 */
@Data
public class NavChartBarVO {

    private List<String> dimensions;

    private List<Map<String, String>> data;

    public NavChartBarVO(Set<String> dimensions, Map<String, Map<String, BigDecimal>> data) {
        this.dimensions = new ArrayList<>(dimensions);
        this.dimensions.add(0, "product");
        this.data = new ArrayList<>();
        data.forEach((key, value) -> {
            Map<String, String> map = new TreeMap<>();
            map.put("product", key);
            map.put(NavCashFlagEnums.ADD.getValue(), value.getOrDefault(NavCashFlagEnums.ADD.getValue(), BigDecimal.ZERO).toString());
            map.put(NavCashFlagEnums.SUB.getValue(), value.getOrDefault(NavCashFlagEnums.SUB.getValue(), BigDecimal.ZERO).toString());
            this.data.add(map);
        });
    }

}
